<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <table>
        <tr>
            <td><input type="text" placeholder="用户名" class="UserName"></td>

        </tr>
        <tr>
            <td>
            <input type="text" placeholder="密码" class="pwd">
            </td>
        </tr>
        <tr>
            <td>
            <input type="button" value="登录" onclick="login()"> 

            </td>
        </tr>
    </table>
</body>

</html>
<script src="./js/jq.js"></script>
<script>
    function login() {
        let user01 = {
            name: 'root',
            pwd: '123456'
        }

        let uName = $('.UserName').val()
        let pwd = $('.pwd').val()

        if (uName === user01.name && pwd === user01.pwd) {
            location.href = 'index.html'
        }else{
            alert('密码错误')
        }
    }
</script>